/**
 * 
 */
package com.nh.action;

import java.sql.Timestamp;

import com.nh.common.DictionaryKey;
import com.nh.entity.NgAdmin;
import com.nh.entity.NgExpertInterlocution;
import com.nh.entity.NgNewsCategory;
import com.opensymphony.xwork2.Action;

/**
 * 项目名称：NotoginsengManage
 * 
 * 类名称：InitAction
 * 
 * 类描述：
 * 
 * 创建人：李兴建
 * 
 * E-mail:lxj08193@163.com
 * 
 * 创建时间：2012-11-9 下午01:22:35
 * 
 * 修改人：李兴建
 * 
 * 修改时间：2012-11-9 下午01:22:35
 * 
 * 修改备注：
 * 
 * @version
 */
public class InitAction extends BaseAction {

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	@Override
	public String execute() throws Exception {
		try {
			//------------------初始化字典----------------------------
			this.putDictionaryValue(DictionaryKey.DICTIONARY_KEY_VERIFICATION, "0");
			this.putDictionaryValue(DictionaryKey.DICTIONARY_KEY_KEYWORD, "");
			this.putDictionaryValue(DictionaryKey.DICTIONARY_KEY_KEYWORD_SETTYPE, "1");
			this.putDictionaryValue(DictionaryKey.DICTIONARY_KEY_CONSULTINGCONNECTION, "");
			// ----------------管理员------------------------
			NgAdmin superAdmin = new NgAdmin();
			superAdmin.setAdminType(1);
			superAdmin.setBeanState(0);
			superAdmin.setCreateadmin("系统自动生成");
			superAdmin.setLoginName("superadmin");
			superAdmin.setLoginPassword("superadmin");
			superAdmin.setRealEname("超级管理员");
			superAdmin.setState(0);
			superAdmin.setCreateTime(new Timestamp(System.currentTimeMillis()));
			this.getBaseService().save(superAdmin);
			this.getBaseService().save(AdminAction.getSuperAdminDefultAuthorization(superAdmin.getId()));

			superAdmin = new NgAdmin();
			superAdmin.setAdminType(0);
			superAdmin.setBeanState(0);
			superAdmin.setCreateadmin("管理员");
			superAdmin.setLoginName("admin");
			superAdmin.setLoginPassword("admin");
			superAdmin.setRealEname("管理员");
			superAdmin.setState(0);
			superAdmin.setCreateTime(new Timestamp(System.currentTimeMillis()));
			this.getBaseService().save(superAdmin);
			this.getBaseService().save(AdminAction.getAdminDefultAuthorization(superAdmin.getId()));

			superAdmin = new NgAdmin();
			superAdmin.setAdminType(2);
			superAdmin.setBeanState(0);
			superAdmin.setCreateadmin("超级管理员");
			superAdmin.setLoginName("zj");
			superAdmin.setLoginPassword("zj");
			superAdmin.setRealEname("专家");
			superAdmin.setState(0);
			superAdmin.setCreateTime(new Timestamp(System.currentTimeMillis()));
			this.getBaseService().save(superAdmin);
			this.getBaseService().save(AdminAction.getExpertDefultAuthorization(superAdmin.getId()));
			
			
			// ----------------默认信息分类------------------------
			NgNewsCategory newsCategory1=new NgNewsCategory();
			newsCategory1.setCreateAdminid("");
			newsCategory1.setCreateTime(new Timestamp(System.currentTimeMillis()));
			newsCategory1.setOder(1);
			newsCategory1.setTitle("快讯");
			newsCategory1.setState(0);
			newsCategory1.setDiscription("系统自动生成，只建议改标题");
			this.getBaseService().save(newsCategory1);
			
			newsCategory1=new NgNewsCategory();
			newsCategory1.setCreateAdminid("");
			newsCategory1.setCreateTime(new Timestamp(System.currentTimeMillis()));
			newsCategory1.setOder(2);
			newsCategory1.setTitle("种植");
			newsCategory1.setState(0);
			newsCategory1.setDiscription("系统自动生成，只建议改标题");
			this.getBaseService().save(newsCategory1);
			
			newsCategory1=new NgNewsCategory();
			newsCategory1.setCreateAdminid("");
			newsCategory1.setCreateTime(new Timestamp(System.currentTimeMillis()));
			newsCategory1.setOder(3);
			newsCategory1.setTitle("防治");
			newsCategory1.setState(0);
			newsCategory1.setDiscription("系统自动生成，只建议改标题");
			this.getBaseService().save(newsCategory1);
			
			newsCategory1=new NgNewsCategory();
			newsCategory1.setCreateAdminid("");
			newsCategory1.setCreateTime(new Timestamp(System.currentTimeMillis()));
			newsCategory1.setOder(4);
			newsCategory1.setTitle("市场");
			newsCategory1.setState(0);
			newsCategory1.setDiscription("系统自动生成，只建议改标题");
			this.getBaseService().save(newsCategory1);
			
			newsCategory1=new NgNewsCategory();
			newsCategory1.setCreateAdminid("");
			newsCategory1.setCreateTime(new Timestamp(System.currentTimeMillis()));
			newsCategory1.setOder(5);
			newsCategory1.setTitle("指导");
			newsCategory1.setState(0);
			newsCategory1.setDiscription("系统自动生成，只建议改标题");
			this.getBaseService().save(newsCategory1);
			
			newsCategory1=new NgNewsCategory();
			newsCategory1.setCreateAdminid("");
			newsCategory1.setCreateTime(new Timestamp(System.currentTimeMillis()));
			newsCategory1.setOder(6);
			newsCategory1.setTitle("资讯");
			newsCategory1.setState(0);
			newsCategory1.setDiscription("系统自动生成，只建议改标题");
			this.getBaseService().save(newsCategory1);
			// ----------------审核------------------------

			// ----------------关键字------------------------

			// ----------------专家咨询------------------------
			NgExpertInterlocution expertInterlocution = new NgExpertInterlocution();
			expertInterlocution.setQuestion("我有一个问题要问一下我有一个问题要问一下我有一个问题要问一下我有一个问题要问一下");
			expertInterlocution.setQuestionTime(new Timestamp(System.currentTimeMillis()));
			expertInterlocution.setState(0);
			expertInterlocution.setUserid(123L);
			expertInterlocution.setUserDiscription("标识为123的用户");
			this.getBaseService().save(expertInterlocution);

			NgExpertInterlocution expertInterlocution2 = new NgExpertInterlocution();
			expertInterlocution2.setQuestion("222222222222222我有一个问题要问一下我有一个问题要问一下我有一个问题要问一下我有一个问题要问一下");
			expertInterlocution2.setQuestionTime(new Timestamp(System.currentTimeMillis()));
			expertInterlocution2.setState(1);
			expertInterlocution2.setUserid(123L);
			expertInterlocution2.setUserDiscription("标识为234的用户");
			expertInterlocution2.setAdminDiscription("标识为dddd的专家");
			expertInterlocution2.setAdminId(234L);
			expertInterlocution2.setAnswer("这个问题我也不知道");
			expertInterlocution2.setAnswerTime(new Timestamp(System.currentTimeMillis()));
			this.getBaseService().save(expertInterlocution2);

		} catch (Exception e) {
			e.printStackTrace();
			return Action.ERROR;
		}

		return Action.SUCCESS;
	}

	

}
